/*
 *  PixelBuffer.cpp
 *  KDTreeRayTracer
 *
 *  Created by steveca  on 09/04/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */
#include "PixelBuffer.h"

namespace RTRT 
{
    PixelBuffer :: PixelBuffer()
        : m_length(0),m_buffer(NULL)
    {
    }

    PixelBuffer :: ~PixelBuffer()
    {
    }

    int PixelBuffer :: createPixelBuffer(unsigned int width, unsigned int height)
    {
        // length of the pixel buffer in bytes
        m_length = width * height * sizeof(Pixel);

        m_width = width;
        m_height = height;

        // Allocate memory for the pixel data
        m_buffer = new Pixel[width*height];

        return m_length;
    }

    int PixelBuffer :: destroy()
    {
        if (m_buffer)
        {
            delete[] m_buffer;
            m_buffer = NULL;
        }
        m_length = 0;
        return 0;
    }

}
